A theory of qualified types